package com.xtx.mapper;

import com.xtx.entity.Address;
import com.xtx.entity.Province;
import com.xtx.vo.AddressVo;
import com.xtx.vo.CountyVo;
import com.xtx.vo.MarketVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AddressMapper {

    @Select("select * from province")
    List<Province> getProvinceList();

    List<MarketVo> getMarketList(Integer id);

    List<CountyVo> getCountyList(Integer id);

    @Select("select name from province where id=#{province}")
    String getProvinceById(Integer province);

    @Select("select name from market where id= #{market}")
    String getMarketById(Integer market);

    @Select("select name from county where id= #{county}")
    String getCountyById(Integer county);

    @Insert("insert into address(name,phone,address,user_id) values(#{name},#{phone},#{address},#{userId})")
    void addAddress(Address address);

    @Select("select * from address where user_id=#{id}")
    List<AddressVo> getAddressList(Integer id);

    @Select("select name from address where id= #{addressId}")
    String getAddressById(Integer addressId);
}
